package j20251009;

public class Demo1 {
    public static void main(String[] args) {
        Thread t=new Thread(()->{
            for(int i=0;i<50;i++){
                try {
                    System.out.println(Thread.currentThread().getName()+"我还活着");
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
            System.out.println(Thread.currentThread().getName()+"我要结束了");
        });
        System.out.println(Thread.currentThread().getName()
                + ": 后台线程"+t.isDaemon());//false
        System.out.println(Thread.currentThread().getName()
                + ": 被中断: " + t.isInterrupted());//false
        t.interrupt();
        System.out.println(Thread.currentThread().getName()
                + ": 被中断: " + t.isInterrupted());//true
        System.out.println(t.isAlive());//false
        t.start();
        System.out.println(t.isAlive());//true
        System.out.println(Thread.currentThread().getName()
                + ": 线程状态"+t.getState());//RUNNABLE
    }
}
